#!/usr/bin/python

# python-resmon - Python tools for Resmon monitoring and the Circonus API
# Copyright (c) 2010 Crown coypright
# 
# This file is part of python-resmon.
# 
# python-resmon is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# python-resmon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with python-resmon.  If not, see <http://www.gnu.org/licenses/>.


import urllib2
import socket

socket.setdefaulttimeout(8)

for l in open('all_hosts.txt'):
    host = l.strip()
    url = 'http://%s:81/' % host
    try:
        resp = urllib2.urlopen(url)
    except (urllib2.HTTPError, urllib2.URLError):
        continue
    if '<ResmonResults>' in resp.read(1024):
        print host
    resp.close()
